<template>
    
    <!-- 组件的模板 -->
    <div class="page approval-detail">
        <template v-for="item in detail">
            <div class="flow com-border-bottom" v-if="item.action_id == 2">
                <h2>{{item.approve_user_name}}审批通过</h2>
                <!-- <p class="note">备注：撒谎打开速度哈夸奖哈空间的哈登记</p> -->
                <div class="time">
                    <span>{{item.create_date}}</span>
                    <span>{{item.create_at}}</span>
                </div>
                <span class="bg_sprite state s1"></span>
            </div>
            <div class="flow com-border-bottom" v-if="item.action_id == 3">
                <h2>审批未通过</h2>
                <p class="note" v-if="item.remark">{{item.remark}}</p>
                <div class="time">
                    <span>{{item.create_date}}</span>
                    <span>{{item.create_at}}</span>
                </div>
                <span class="bg_sprite state s2"></span>
            </div>
            <div class="flow com-border-bottom" v-if="item.action_id == 1">
                <h2>{{item.create_user_name}}提交了工资单给{{item.approve_user_name}}审批</h2>
                <!-- <p class="note">备注：撒谎打开速度哈夸奖哈空间的哈登记哈</p> -->
                <div class="time">
                    <span>{{item.create_date}}</span>
                    <span>{{item.create_at}}</span>
                </div>
                <span class="bg_sprite state s0"></span>
            </div>
            <div class="flow com-border-bottom" v-if="item.action_id == 4">
                <h2>工资单支付成功</h2>
                <!-- <p class="note">备注：撒谎打开速度哈夸奖哈空间的哈登记哈</p> -->
                <div class="time">
                    <span>{{item.create_date}}</span>
                    <span>{{item.create_at}}</span>
                </div>
                <span class="bg_sprite state s1"></span>
            </div>
            <div class="flow com-border-bottom" v-if="item.action_id == 5">
                <h2>工资单支付失败</h2>
                <!-- <p class="note">备注：撒谎打开速度哈夸奖哈空间的哈登记哈</p> -->
                <div class="time">
                    <span>{{item.create_date}}</span>
                    <span>{{item.create_at}}</span>
                </div>
                <span class="bg_sprite state s2"></span>
            </div>
        </template>  
    </div>
</template>

<script>
    /**
     *  引入工具类库 或 Native API
     *  example : import widget from 'gapi/widget'
     */
    import * as util from 'js/util.js'
    import commonPage from 'clientApi/commonPage.js'
    import widget from 'gapi/widget'
    /**
     *  引入组件 以及 组件接口(Action)
     *  example : import Somecomponents from 'components/Somecomponents/Somecomponents'
     */

    /**
     *  组件实例对象
     */
    export default {
        components: {

        },
        data: function(){
            return{
                team_id: 0,
                project_id: 0,
                order_id: 0,
                detail:  [
                    // {
                    //     "create_user_name": "zhangsan",
                    //     "approve_user_name": "lisi",
                    //     "action_id": 1, //1:提交工资单,待审批 2:审批通过工资单 3:审批驳回工资单
                    //     "remark": "",
                    //     create_at: "18:40",
                    //     create_date: "2017-03-26"
                    // },
                    // {
                    //     "create_user_name": "zhangsan",
                    //     "approve_user_name": "lisi",
                    //     "action_id": 2,
                    //     "remark": "123456这里是备注",
                    //     create_at: "18:40",
                    //     create_date: "2017-03-26"
                    // },
                    // {
                    //     "create_user_name": "zhangsan",
                    //     "approve_user_name": "lisi",
                    //     "action_id": 0,
                    //     "remark": "",
                    //     create_at: "18:40",
                    //     create_date: "2017-03-26"
                    // }
                ]
            }
        },
        vuex: {
            getters: {

            },
            actions: {

            }
        },
        methods: {
            /**
             * 初始化
             * @method init
             * @public
             * @return {Null} void
             */
            init (){
                this.team_id = util.getUrddataString('team_id')
                this.project_id = util.getUrddataString('project_id')
                this.order_id = util.getUrddataString('order_id')

                //获取审批记录详情
                this.getData()
                
            },
            getData(){
                commonPage.loadPageStatus('loading')
                util.ajax({
                    url:'/wage/approval/detail',
                    type:'GET',
                    data:{
                        team_id: this.team_id,
                        project_id: this.project_id,
                        order_id: this.order_id
                    },
                    timeout:10000,
                    success:(result) => {
                        console.log(result)
                        commonPage.loadPageStatus('loadSuccess')
                        if(result&&result.errno == 0){
                            this.detail = result.data.result
                        }else{
                            widget.toast(result.errmsg)
                        }
                    },
                    error: (xhr, status) => {
                        commonPage.loadPageStatus('loadSuccess')
                        widget.toast('服务器异常')
                    },
                    noNetwork: () => {
                        commonPage.loadPageStatus('loadSuccess')
                        widget.toast('网络连接失败，请检查网络')
                    }
                })
            },
            // disDate(timestr, label){
            //     if(label === 'ymd'){
            //         return util.getLocalTime(new Date().getTime(),'yyyy-MM-dd')
            //     }else if(label === 'hm'){
            //         return util.getLocalTime(new Date().getTime(),'HH:mm')
            //     }
            // }
        },
        created(){

            this.init();
            
        }
        
    }

    
</script>

<!-- CSS 样式 -->
<style src="../../node_modules/weui/dist/style/weui.css"></style>
<style src="../../static/css/common.css"></style>
<style src="../../static/css/salary.css"></style>



